﻿@using CubicFWNet.Data.Models
@using CubicFWNet.Data.ViewModal
@model CubicFWNet.Data.Models.Order
@{
    //var product = ViewBag.Product as Product;
    var invoice = ViewBag.Invoice as Invoice;
    var sc = ViewBag.SendCar as SendCar;
    var exp = ViewBag.ExpressOrder as ExpressOrder;
    var customerShortName = ViewBag.CustomerShortName;
}
<section class="content-header">
    <h1>
        发货单详情
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("InvoiceQuery", "Order")">发货单查询</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                @if (Model != null && invoice != null)
                {
                    <form class="form-horizontal" id="frmedit" action="@Url.Action("AddInvoice", "Order")" method="post">
                        <input type="hidden" id="OrderId" name="OrderId" value="@Model.Id" />
                        <div class="box-body">
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">发货单号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="Number" name="Number" value="@invoice.Number" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">订单号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="OrderNumber" name="OrderNumber" value="@Model.Number" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">收货单位</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="TakeCompany" name="TakeCompany" value="@invoice.TakeCompany" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">简称</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="customerShortName" name="customerShortName" value="@customerShortName" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">填单日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationTime" name="operationTime" placeholder="" value="@invoice.CreateTime" readonly="readonly">
                                </div>
                            </div>
                            
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">发货日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="DliveryTime" name="DliveryTime" value="@invoice.DliveryTime" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">预计到货日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="ReceivedTime" name="ReceivedTime" value="@invoice.ReceivedTime" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6" style="display: none">
                                <label class="col-sm-3 control-label">收货人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="ReceivePeople" name="ReceivePeople" value="@invoice.ReceivePeople" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">发货人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="SendPeople" name="SendPeople" value="@invoice.SendPeople" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">送货要求</label>
                                <div class="col-sm-9">
                                    <textarea class="form-control" rows="3" placeholder="请输入 ..." name="DliveryDemand" id="DliveryDemand" readonly="readonly">@invoice.DliveryDemand</textarea>
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>

                            <div id="json-content" class="col-md-12 ">
                                @*col-md-offset-1*@
                                @*<div class="form-group col-md-6">
                                        <label class="col-sm-3 control-label">数量</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control okeydown" data-des="数量" id="Amount" name="Amount" value="@tmView.Amount">
                                        </div>
                                    </div>*@
                                <input type="hidden" id="modalData" value="@invoice.Data" readonly="readonly">
                                <table class="footable table table-stripped table-bordered table-hover" id="footable">
                                    <thead>
                                        <tr>
                                            <th data-sort-ignore="true">
                                                品名
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                尺寸宽-mm
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                尺寸长-mm
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                基本单位
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true" class="col-md-2">
                                                数量
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true" class="col-md-2">
                                                价格
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                金额
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody id="data-content"></tbody>
                                </table>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            @if (invoice.Type == 1 && sc != null)
                            {
                                <div id="car">
                                    <div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">客户名称</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" value="@customerShortName" readonly="readonly">
                                        </div>
                                    </div>
                                    
                                    @*<div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">发货单编号</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" id="Number" name="Number" value="@sc.Number" readonly="readonly" />
                                        </div>
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">货物总值</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" id="Worth" name="Worth" value="@sc.Worth" readonly="readonly" />
                                        </div>
                                    </div>*@
                                    <div class="form-group col-md-6">
                                        <label class="col-sm-3 control-label">送货要求</label>
                                        <div class="col-sm-9">
                                            <textarea class="form-control" rows="3" placeholder="请输入 ..." name="Demand" id="Demand" readonly="readonly">@sc.Demand</textarea>
                                        </div>
                                    </div>
                                </div>
                            }
                            @if (invoice.Type == 2 && exp != null)
                            {
                                <div id="express">
                                    <div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">客户名称</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" value="@customerShortName" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">快递名称</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" id="ExpTypeName" name="ExpTypeName" value="@exp.ExpTypeName" readonly="readonly" />
                                        </div>
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">快递编号</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" id="ExpNumber" name="ExpNumber" value="@exp.ExpNumber" readonly="readonly"/>
                                        </div>
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label for="operationName" class="col-sm-3 control-label">付费方式</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" id="PayType" name="PayType" value="@exp.PayType" readonly="readonly" />
                                        </div>
                                    </div>
                                </div>
                            }
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label for="operationName" class="col-sm-3 control-label">操作人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationName" name="operationName" value="@invoice.CreatorName" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="operationTime" class="col-sm-3 control-label">日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationTime" name="operationTime" value="@invoice.CreateTime" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="box-footer" style="width: 80%; margin-left: 20px;">
                            <a class="btn btn-primary submitbtn" href="@Url.Action("InvoiceQuery", "Order")">返回</a>
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</section>

<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {

            //日期控件
            $(".Timedatepicker").datepicker({
                autoclose: true,
                language: 'zh', //汉化
                format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
                minView: "month" //选择日期后，不会再跳转去选择时分秒
            });

            var yy = document.getElementById("modalData").value;
            if (yy != "") {
                var data = JSON.parse(document.getElementById("modalData").value);
                var $content = $('#data-content');
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    html += "<tr class='tr'>";
                    html += "<td>" + data[i].ProductName + "</td>";
                    html += "<td>" + data[i].ProductSizeWidth + "</td>";
                    html += "<td>" + data[i].ProductSizeWidth + "</td>";
                    html += "<td>" + data[i].ProductUnit + "</td>";
                    html += "<td>" + data[i].ProductAmount + "</td>";
                    html += "<td>" + data[i].ProductPrice + "</td>";
                    html += "<td>" + data[i].TotalMoney + "</td>";
                    html += "</tr>";
                }

                $content.append(html);
            }


            $('#footable').footable();
        });

        var type = 1;

        function formsubmit(t) {
            type = t;
            $("#frmedit").submit();
        }

        $(".itemAmount").keyup(function () {
            var amount = $(this).val() / 1;
            var price = $(this).attr('data-itemprice');
            var b = (amount * price).toFixed(2);
            $(this).parents(".tr").find(".itemMoney").val(b);
        });

        $(".okeydown").on("keydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });


    </script>
}